package com.scst.controller.user;

import com.scst.result.Result;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/shop")
@Slf4j
public class ShopController {
    @Autowired
    RedisTemplate redisTemplate;
    @PutMapping("#{status}")
    @ApiOperation("设置店铺营业状态")
    public Result setStatus(Integer status) {
        log.info("店铺的营业状态为:{}",status==1?"营业中":"打样中");
        redisTemplate .opsForValue().set("SHOP_STATUS","1");
        return Result.success();
    }
    @GetMapping("/status")
    @ApiOperation("获取店铺营业状态")
    public Result<Integer> getStatus() {
        Integer status=(Integer)redisTemplate.opsForValue().get("SHOP_STATUS");
        return Result.success(status);
    }
}
